package newPan3d.content.role
{
	import _Pan3D.display3D.Display3DContainer;
	import _Pan3D.display3D.analysis.ObjAnalysis;
	import _Pan3D.program.Program3DManager;
	import _Pan3D.program.shaders.Md5Shader;
	import _Pan3D.role.Hero;
	import _Pan3D.role.Role;
	import _Pan3D.role.RoleVo;
	
	import _me.Scene_data;
	
	import flash.display3D.Context3D;
	import flash.display3D.Program3D;
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.drm.VoucherAccessInfo;

	public class HeroLevle
	{
		private var roleContainer : Display3DContainer;
		private var role:Hero;
		public function HeroLevle()
		{
			loadRoleConfig();
		}
		private function addRole(info:RoleVo):void
		{
			var context3D : Context3D = Scene_data.context3D;
			
			role = new Hero(context3D,info);
			
			role.scale=0.05;
			role.x=500
			role.y=-30
			role.z=500
			role.rotationY=0
			role.frameRate = 0;
			roleContainer=new Display3DContainer;
			roleContainer.addChild(role);
			var md5Program:Program3D = Program3DManager.getInstance().getProgram(Md5Shader.MD5SHADER);
			role.setProgram3D(md5Program);
			
			Scene_data.self3DMove=role;
			
			
			
			
		}
		public function upData():void
		{
			if(roleContainer)
				roleContainer.update();
		}
		private function loadRoleConfig():void{
			var urlloader:URLLoader = new URLLoader();
			urlloader.addEventListener(Event.COMPLETE,onCom);
			urlloader.load(new URLRequest("../_File/nijia2/role/hero.xml"));
		}
		private function onCom(event:Event):void{
			var xml:XML = XML(event.target.data);
			var name:String = String(xml.name);
			var equipment:Object = new Object
			for each (var prop:XML in xml.equipment.prop)
			{
				equipment[String(prop.@place)] = String(prop.@url);
			}
			var action:Object = new Object;
			for each (prop in xml.action.prop)
			{
				var obj:Object = new Object;
				obj.url = String(prop.@url);
				obj.zyklus = Boolean(int(prop.@zyklus))
				action[String(prop.@name)] = obj;
			}
			
			var info:RoleVo = new RoleVo;
			info.name = name;
			info.equipment = equipment;
			info.action = action;
			
			addRole(info);
		}
	}
}